const mysql = require("mysql2");
// 创建本地连接池
const connectionPool = mysql.createPool({
  host: "localhost",
  port: 3306,
  database: "keep_youth",
  user: "root",
  password: "admin",
  connectionLimit: 5,
});
// 获取连接是否成功
connectionPool.getConnection((err, connection) => {
  if (err) {
    console.log("数据库连接失败", err);
  } else {
    console.log("数据库连接成功");
  }
});
/**获取连接池中的连接对象(Promise) */
const connection = connectionPool.promise();
module.exports = connection;
